package com.hncc.dms.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hncc.dms.domain.DmsCaseModel;
import com.hncc.dms.service.IDmsCaseModelService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;

/**
 * 病历模版Controller
 * 
 * @author ruoyi
 * @date 2020-08-23
 */
@RestController
@RequestMapping("/dms/case_model")
@Api(tags = "病历模版接口")
public class DmsCaseModelController extends BaseController
{
    @Resource
    private IDmsCaseModelService dmsCaseModelService;

    /**
     * 查询病历模版列表
     */
    @ApiOperation(value = "条件分页查询病历模版",httpMethod = "GET")
    @PreAuthorize("@ss.hasPermi('dms:case_model:list')")
    @GetMapping("/list")
    public TableDataInfo list(DmsCaseModel dmsCaseModel)
    {
        startPage();
        List<DmsCaseModel> list = dmsCaseModelService.selectDmsCaseModelList(dmsCaseModel);
        return getDataTable(list);
    }

    /**
     * 导出病历模版列表
     */
    @PreAuthorize("@ss.hasPermi('dms:case_model:export')")
    @Log(title = "病历模版", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DmsCaseModel dmsCaseModel)
    {
        List<DmsCaseModel> list = dmsCaseModelService.selectDmsCaseModelList(dmsCaseModel);
        ExcelUtil<DmsCaseModel> util = new ExcelUtil<DmsCaseModel>(DmsCaseModel.class);
        return util.exportExcel(list, "case_model");
    }

    /**
     * 获取病历模版详细信息
     */
    @ApiOperation(value = "根据id获取病历模版详细信息",httpMethod = "GET",
            notes = "根据id查询病历模版")
    @ApiImplicitParam(paramType = "path",name = "id",value = "病历模版id",dataType = "Long",required = true)
    @PreAuthorize("@ss.hasPermi('dms:case_model:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(dmsCaseModelService.selectDmsCaseModelById(id));
    }

    /**
     * 新增病历模版
     */
    @ApiOperation(value = "新增",httpMethod = "POST", notes = "新增病历模版")
    @ApiImplicitParam(name = "dmsCaseModel", value = "新增病历模版", dataType = "DmsCaseModel")
    @PreAuthorize("@ss.hasPermi('dms:case_model:add')")
    @Log(title = "病历模版", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsCaseModel dmsCaseModel)
    {
        return toAjax(dmsCaseModelService.insertDmsCaseModel(dmsCaseModel));
    }

    /**
     * 修改病历模版
     */
    @ApiOperation(value = "修改", httpMethod = "PUT", notes = "修改病历模版")
    @ApiImplicitParam(name = "dmsCaseModel", value = "修改病历模版", dataType = "DmsCaseModel")
    @PreAuthorize("@ss.hasPermi('dms:case_model:edit')")
    @Log(title = "病历模版", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsCaseModel dmsCaseModel)
    {
        return toAjax(dmsCaseModelService.updateDmsCaseModel(dmsCaseModel));
    }

    /**
     * 删除病历模版
     */
    @ApiOperation(value = "批量删除", httpMethod = "DELETE", notes = "根据ids删除病历模版")
    @ApiImplicitParam(paramType = "path",name = "ids",value = "病历模版id",dataType = "Long[]",required = true)
    @PreAuthorize("@ss.hasPermi('dms:case_model:remove')")
    @Log(title = "病历模版", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dmsCaseModelService.deleteDmsCaseModelByIds(ids));
    }
}
